/*
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software Foundation,
 *    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

/*
 * DisplayDialog.java
 *
 * Created on 2009-11-09, 16:48:02
 */

package JET.Frames;

import JET.Centers.ControlCenter;
import JET.Scene;

/**
 *
 * @author 057Ry
 */
public class DisplayDialog extends javax.swing.JDialog {

    static final ControlCenter CC = ControlCenter.getInstance();
    private Scene scene;
    
    /** Creates new form DisplayDialog */
    public DisplayDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        scene = CC.getCurrentScene();

        drawWallsCheckBox.setSelected( scene.GC.isDrawWalls2d() );
        drawWallsNumbersCheckBox1.setSelected(scene.GC.isDrawWallsNumbers());
        drawSpringsCheckBox.setSelected(scene.GC.isDrawSprings2d());
        drawSpringsNumbersCheckBox1.setSelected(scene.GC.isDrawSpringsNumbers());
        drawMassesCheckBox.setSelected(scene.GC.isDrawMasses2d());
        drawMassesNumbersCheckBox.setSelected(scene.GC.isDrawMassesNumbers());
        drawMassesMoveCheckBox.setSelected(scene.GC.isDrawMass2dIfMoved());
        drawBoundingBoxCheckBox.setSelected(scene.GC.isDrawBoundingBoxes());
        drawCollisionsCheckBox1.setSelected(scene.GC.isDrawSpringBodyCollisions());
        drawGeomCenterCheckBox.setSelected(scene.GC.isDrawSpringBodyGeomCenter());
        drawBorderOrientationCheckBox.setSelected(scene.GC.isDrawBorderOrientation());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        drawMassesMoveCheckBox = new javax.swing.JCheckBox();
        drawMassesCheckBox = new javax.swing.JCheckBox();
        drawMassesNumbersCheckBox = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        drawSpringsCheckBox = new javax.swing.JCheckBox();
        drawSpringsNumbersCheckBox1 = new javax.swing.JCheckBox();
        jPanel3 = new javax.swing.JPanel();
        drawWallsCheckBox = new javax.swing.JCheckBox();
        drawWallsNumbersCheckBox1 = new javax.swing.JCheckBox();
        drawBoundingBoxCheckBox = new javax.swing.JCheckBox();
        drawCollisionsCheckBox1 = new javax.swing.JCheckBox();
        drawGeomCenterCheckBox = new javax.swing.JCheckBox();
        drawBorderOrientationCheckBox = new javax.swing.JCheckBox();
        optimToggleButton = new javax.swing.JToggleButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Display options");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jButton1.setText("Close");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Masses"));

        drawMassesMoveCheckBox.setText("Draw mass move");
        drawMassesMoveCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawMassesMoveCheckBoxActionPerformed(evt);
            }
        });

        drawMassesCheckBox.setSelected(true);
        drawMassesCheckBox.setText("Draw masses");
        drawMassesCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawMassesCheckBoxActionPerformed(evt);
            }
        });

        drawMassesNumbersCheckBox.setText("Draw numbers");
        drawMassesNumbersCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawMassesNumbersCheckBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(drawMassesCheckBox)
                    .addComponent(drawMassesNumbersCheckBox)
                    .addComponent(drawMassesMoveCheckBox))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(drawMassesCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(drawMassesNumbersCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(drawMassesMoveCheckBox))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Springs"));

        drawSpringsCheckBox.setSelected(true);
        drawSpringsCheckBox.setText("Draw springs");
        drawSpringsCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawSpringsCheckBoxActionPerformed(evt);
            }
        });

        drawSpringsNumbersCheckBox1.setText("Draw numbers");
        drawSpringsNumbersCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawSpringsNumbersCheckBox1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(drawSpringsCheckBox)
                    .addComponent(drawSpringsNumbersCheckBox1))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(drawSpringsCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(drawSpringsNumbersCheckBox1)
                .addContainerGap(23, Short.MAX_VALUE))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Spring Bodies"));

        drawWallsCheckBox.setSelected(true);
        drawWallsCheckBox.setText("Draw walls");
        drawWallsCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawWallsCheckBoxActionPerformed(evt);
            }
        });

        drawWallsNumbersCheckBox1.setText("Draw wall numbers");
        drawWallsNumbersCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawWallsNumbersCheckBox1ActionPerformed(evt);
            }
        });

        drawBoundingBoxCheckBox.setText("Draw BoundingBoxes");
        drawBoundingBoxCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawBoundingBoxCheckBoxActionPerformed(evt);
            }
        });

        drawCollisionsCheckBox1.setText("Draw collisions");
        drawCollisionsCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawCollisionsCheckBox1ActionPerformed(evt);
            }
        });

        drawGeomCenterCheckBox.setSelected(true);
        drawGeomCenterCheckBox.setText("Draw geometry center");
        drawGeomCenterCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawGeomCenterCheckBoxActionPerformed(evt);
            }
        });

        drawBorderOrientationCheckBox.setText("Draw border orient.");
        drawBorderOrientationCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                drawBorderOrientationCheckBoxActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(drawWallsCheckBox)
                            .addComponent(drawWallsNumbersCheckBox1))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(drawBoundingBoxCheckBox)
                            .addComponent(drawCollisionsCheckBox1)))
                    .addComponent(drawGeomCenterCheckBox)
                    .addComponent(drawBorderOrientationCheckBox))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(drawBoundingBoxCheckBox)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(drawCollisionsCheckBox1))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(drawWallsCheckBox)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(drawWallsNumbersCheckBox1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(drawBorderOrientationCheckBox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(drawGeomCenterCheckBox)
                .addContainerGap())
        );

        optimToggleButton.setSelected(CC.optimizeDrawing);
        optimToggleButton.setText("Drawing Optimization");
        optimToggleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                optimToggleButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(optimToggleButton, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(122, 122, 122)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(optimToggleButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void drawMassesMoveCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawMassesMoveCheckBoxActionPerformed
        scene.GC.setDrawMass2dIfMoved(!scene.GC.isDrawMass2dIfMoved());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawMassesMoveCheckBoxActionPerformed

    private void drawMassesCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawMassesCheckBoxActionPerformed
        scene.GC.setDrawMasses2d(!scene.GC.isDrawMasses2d());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawMassesCheckBoxActionPerformed

    private void drawSpringsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawSpringsCheckBoxActionPerformed
        scene.GC.setDrawSprings2d(!scene.GC.isDrawSprings2d());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawSpringsCheckBoxActionPerformed

    private void drawWallsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawWallsCheckBoxActionPerformed
        scene.GC.setDrawWalls2d(!scene.GC.isDrawWalls2d());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawWallsCheckBoxActionPerformed

    private void drawMassesNumbersCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawMassesNumbersCheckBoxActionPerformed
        scene.GC.setDrawMassesNumbers(!scene.GC.isDrawMassesNumbers());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawMassesNumbersCheckBoxActionPerformed

    private void drawSpringsNumbersCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawSpringsNumbersCheckBox1ActionPerformed
        scene.GC.setDrawSpringsNumbers(!scene.GC.isDrawSpringsNumbers());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawSpringsNumbersCheckBox1ActionPerformed

    private void drawWallsNumbersCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawWallsNumbersCheckBox1ActionPerformed
        scene.GC.setDrawWallsNumbers(!scene.GC.isDrawWallsNumbers());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawWallsNumbersCheckBox1ActionPerformed

    private void drawBoundingBoxCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawBoundingBoxCheckBoxActionPerformed
        scene.GC.setDrawBoundingBoxes(!scene.GC.isDrawBoundingBoxes());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawBoundingBoxCheckBoxActionPerformed

    private void drawCollisionsCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawCollisionsCheckBox1ActionPerformed
        scene.GC.setDrawSpringBodyCollisions(!scene.GC.isDrawSpringBodyCollisions());
        CC.GUIC.repaintAllSceneTabs();
}//GEN-LAST:event_drawCollisionsCheckBox1ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void drawGeomCenterCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawGeomCenterCheckBoxActionPerformed
        scene.GC.setDrawSpringBodyGeomCenter( !scene.GC.isDrawSpringBodyGeomCenter() );
}//GEN-LAST:event_drawGeomCenterCheckBoxActionPerformed

    private void drawBorderOrientationCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_drawBorderOrientationCheckBoxActionPerformed
        scene.GC.setDrawBorderOrientation( !scene.GC.isDrawBorderOrientation() );
    }//GEN-LAST:event_drawBorderOrientationCheckBoxActionPerformed

    private void optimToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_optimToggleButtonActionPerformed
        CC.optimizeDrawing = optimToggleButton.isSelected();
    }//GEN-LAST:event_optimToggleButtonActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
    }//GEN-LAST:event_formWindowClosed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox drawBorderOrientationCheckBox;
    private javax.swing.JCheckBox drawBoundingBoxCheckBox;
    private javax.swing.JCheckBox drawCollisionsCheckBox1;
    private javax.swing.JCheckBox drawGeomCenterCheckBox;
    private javax.swing.JCheckBox drawMassesCheckBox;
    private javax.swing.JCheckBox drawMassesMoveCheckBox;
    private javax.swing.JCheckBox drawMassesNumbersCheckBox;
    private javax.swing.JCheckBox drawSpringsCheckBox;
    private javax.swing.JCheckBox drawSpringsNumbersCheckBox1;
    private javax.swing.JCheckBox drawWallsCheckBox;
    private javax.swing.JCheckBox drawWallsNumbersCheckBox1;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JToggleButton optimToggleButton;
    // End of variables declaration//GEN-END:variables

}
